<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="http://mat1.gtimg.com/libs/jquery2/2.2.0/jquery.js"></script>
</head>
<body>
{#<form action="" method="post">#}

账号： <input type="text" name="uname" id="name">
密码： <input type="text" name="pwd" id="pwd">
<button onclick="f()" id="btn">登录</button>

{#</form>#}
<script>
        {#$("#btn").click(#}
    function f() {
        {#    function () {#}
                var name = $('#name').val()
                var pwd = $('#pwd').val()
                $.ajax({
                    type: 'POST',
                    url: '/loginoy/',
                    data: {
                        'name': name,
                        'pwd': pwd
                    },
                    success: function (result) {
                        {#var i = JSON.parse(result)#}
                        console.log(result);
                        if (result.flag===1) {

                            location.href = '{% url 'all' %}'
                        } else {
                            alert('密码账号错误')
                        }
                    },
                    error: function () {
                        alert('服务器出错')
                    }
                })
           // }
        {#)#}
    }
</script>
</body>
</html>